/*
* Copyright (C) 1997-2001 Id Software, Inc.
* 
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
* 
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE.
* 
* See the GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
*  
*/

// Created on 31.10.2003 by RST.
// $Id: game_import_t.java,v 1.7 2006/01/21 21:53:31 salomo Exp $
using System;
using Defines = Suake2.UI.Defines;
using Suake2.UI.qcommon;
using Suake2.UI.server;
namespace Suake2.UI.game
{
	
	//
	//	collection of functions provided by the main engine
	//
	public class game_import_t
	{
		public game_import_t()
		{
			InitBlock();
		}
		//UPGRADE_NOTE: Field 'EnclosingInstance' was added to class 'AnonymousClassPointContentsAdapter' to access its enclosing instance. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1019'"
		public class AnonymousClassPointContentsAdapter:pmove_t.PointContentsAdapter
		{
			public AnonymousClassPointContentsAdapter(jake2.game.pmove_t enclosingInstance)
			{
				InitBlock(enclosingInstance);
			}
			private void  InitBlock(jake2.game.pmove_t enclosingInstance)
			{
				this.enclosingInstance = enclosingInstance;
			}
			private jake2.game.pmove_t enclosingInstance;
			public jake2.game.pmove_t Enclosing_Instance
			{
				get
				{
					return enclosingInstance;
				}
				
			}
			public override int pointcontents(float[] o)
			{
				return 0;
			}
		}
		private void  InitBlock()
		{
			pointcontents = new AnonymousClassPointContentsAdapter(this);
		}
		// special messages
		public virtual void  bprintf(int printlevel, System.String s)
		{
			SV_SEND.SV_BroadcastPrintf(printlevel, s);
		}
		
		public virtual void  dprintf(System.String s)
		{
			SV_GAME.PF_dprintf(s);
		}
		
		public virtual void  cprintf(edict_t ent, int printlevel, System.String s)
		{
			SV_GAME.PF_cprintf(ent, printlevel, s);
		}
		
		public virtual void  centerprintf(edict_t ent, System.String s)
		{
			SV_GAME.PF_centerprintf(ent, s);
		}
		
		public virtual void  sound(edict_t ent, int channel, int soundindex, float volume, float attenuation, float timeofs)
		{
			SV_GAME.PF_StartSound(ent, channel, soundindex, volume, attenuation, timeofs);
		}
		
		public virtual void  positioned_sound(float[] origin, edict_t ent, int channel, int soundinedex, float volume, float attenuation, float timeofs)
		{
			
			SV_SEND.SV_StartSound(origin, ent, channel, soundinedex, volume, attenuation, timeofs);
		}
		
		// config strings hold all the index strings, the lightstyles,
		// and misc data like the sky definition and cdtrack.
		// All of the current configstrings are sent to clients when
		// they connect, and changes are sent to all connected clients.
		public virtual void  configstring(int num, System.String string_Renamed)
		{
			SV_GAME.PF_Configstring(num, string_Renamed);
		}
		
		public virtual void  error(System.String err)
		{
			Com.Error(Defines.ERR_FATAL, err);
		}
		
		public virtual void  error(int level, System.String err)
		{
			SV_GAME.PF_error(level, err);
		}
		
		// the *index functions create configstrings and some internal server state
		public virtual int modelindex(System.String name)
		{
			return SV_INIT.SV_ModelIndex(name);
		}
		
		public virtual int soundindex(System.String name)
		{
			return SV_INIT.SV_SoundIndex(name);
		}
		
		public virtual int imageindex(System.String name)
		{
			return SV_INIT.SV_ImageIndex(name);
		}
		
		public virtual void  setmodel(edict_t ent, System.String name)
		{
			SV_GAME.PF_setmodel(ent, name);
		}
		
		// collision detection
		public virtual trace_t trace(float[] start, float[] mins, float[] maxs, float[] end, edict_t passent, int contentmask)
		{
			return SV_WORLD.SV_Trace(start, mins, maxs, end, passent, contentmask);
		}
		
		//UPGRADE_NOTE: The initialization of  'pointcontents' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		public pmove_t.PointContentsAdapter pointcontents;
		
		public virtual bool inPHS(float[] p1, float[] p2)
		{
			return SV_GAME.PF_inPHS(p1, p2);
		}
		
		public virtual void  SetAreaPortalState(int portalnum, bool open)
		{
			CM.CM_SetAreaPortalState(portalnum, open);
		}
		
		public virtual bool AreasConnected(int area1, int area2)
		{
			return CM.CM_AreasConnected(area1, area2);
		}
		
		// an entity will never be sent to a client or used for collision
		// if it is not passed to linkentity. If the size, position, or
		// solidity changes, it must be relinked.
		public virtual void  linkentity(edict_t ent)
		{
			SV_WORLD.SV_LinkEdict(ent);
		}
		
		public virtual void  unlinkentity(edict_t ent)
		{
			SV_WORLD.SV_UnlinkEdict(ent);
		}
		
		// call before removing an interactive edict
		public virtual int BoxEdicts(float[] mins, float[] maxs, edict_t[] list, int maxcount, int areatype)
		{
			return SV_WORLD.SV_AreaEdicts(mins, maxs, list, maxcount, areatype);
		}
		
		public virtual void  Pmove(pmove_t pmove)
		{
			PMove.Pmove(pmove);
		}
		
		// player movement code common with client prediction
		// network messaging
		public virtual void  multicast(float[] origin, int to)
		{
			SV_SEND.SV_Multicast(origin, to);
		}
		
		public virtual void  unicast(edict_t ent, bool reliable)
		{
			SV_GAME.PF_Unicast(ent, reliable);
		}
		
		
		public virtual void  WriteByte(int c)
		{
			SV_GAME.PF_WriteByte(c);
		}
		
		public virtual void  WriteShort(int c)
		{
			SV_GAME.PF_WriteShort(c);
		}
		
		public virtual void  WriteString(System.String s)
		{
			SV_GAME.PF_WriteString(s);
		}
		
		public virtual void  WritePosition(float[] pos)
		{
			SV_GAME.PF_WritePos(pos);
		}
		
		// some fractional bits
		public virtual void  WriteDir(float[] pos)
		{
			SV_GAME.PF_WriteDir(pos);
		}
		
		// console variable interaction
		public virtual cvar_t cvar(System.String var_name, System.String value_Renamed, int flags)
		{
			return Cvar.Get(var_name, value_Renamed, flags);
		}
		
		// console variable interaction
		public virtual cvar_t cvar_set(System.String var_name, System.String value_Renamed)
		{
			return Cvar.Set(var_name, value_Renamed);
		}
		
		// console variable interaction
		public virtual cvar_t cvar_forceset(System.String var_name, System.String value_Renamed)
		{
			return Cvar.ForceSet(var_name, value_Renamed);
		}
		
		// ClientCommand and ServerCommand parameter access
		public virtual int argc()
		{
			return Cmd.Argc();
		}
		
		
		public virtual System.String argv(int n)
		{
			return Cmd.Argv(n);
		}
		
		// concatenation of all argv >= 1
		public virtual System.String args()
		{
			return Cmd.Args();
		}
		
		// add commands to the server console as if they were typed in
		// for map changing, etc
		public virtual void  AddCommandString(System.String text)
		{
			Cbuf.AddText(text);
		}
	}
}